import { BaseTableState } from '#/core'
import { MenuItem } from '@/api/userCenter/system/model/menuModel'
import { RoleItem } from '@/api/userCenter/authority/model/roleModel'
import { MenuItemWithoutIcon } from '@/utils/routeHelper'
import { ValidationRule } from 'ant-design-vue/lib/form/Form'

export type TableStateWrapper = BaseTableState<RoleItem>
export type DrawerFormData = Omit<RoleItem, 'id'>

export enum BtnPerm {
  QUERY = 'uc-system-rolc-query',
  ADD = 'uc-system-rolc-add',
  EDIT = 'uc-system-rolc-edit',
  DELETE = 'uc-system-rolc-delete',
}
export interface DrawerState {
  visiable: boolean
  title: string
  type: 'add' | 'edit'
  formData: DrawerFormData
  formRules: { [key: string]: ValidationRule | ValidationRule[] }
  labelCol: { span: number }
  wrapperCol: { span: number }
  /** 权限树当前选中节点 */
  treeCheckedKeys: { checked: string[]; halfChecked: string[] }
  /** antd 树组件字段替换 */
  treeReplaceFields: { [key: string]: string }
  /** 当前权限树数据 */
  treeData: MenuItemWithoutIcon[]
  /** 全量权限树拍平展开数据 */
  treeFlatData: { [key: string]: MenuItem }
  /** 默认权限树展开节点 */
  treeExpandedKeys: string[]
  currentApp: string
  /** 全量权限树数据 */
  allPermData: MenuItemWithoutIcon[]
  selectAppDisable: boolean
}

export interface TreeCheckEvent {
  checkedNodes: { props: MenuItem }[]
  checked: boolean
  node: { dataRef: { children?: MenuItem[] } }
}
